using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class UDF_FieldTypeMap : EntityTypeConfiguration<UDF_FieldType>
    {
        public UDF_FieldTypeMap()
        {
            // Primary Key
            this.HasKey(t => t.id);

            // Properties
            this.Property(t => t.Name)
                .HasMaxLength(100);

            this.Property(t => t.ControlType)
                .HasMaxLength(20);

            this.Property(t => t.DataType)
                .HasMaxLength(20);

            this.Property(t => t.RecordType)
                .HasMaxLength(20);

            this.Property(t => t.Category)
                .HasMaxLength(20);

            this.Property(t => t.ValueList)
                .HasMaxLength(5000);

            this.Property(t => t.NoteSelectionCode)
                .HasMaxLength(50);

            this.Property(t => t.Message)
                .HasMaxLength(200);

            this.Property(t => t.ReportCode)
                .HasMaxLength(30);

            this.Property(t => t.StatsCode)
                .HasMaxLength(30);

            this.Property(t => t.ImageFile)
                .HasMaxLength(100);

            this.Property(t => t.Name_Arabic)
                .HasMaxLength(100);

            this.Property(t => t.Visibility)
                .IsFixedLength()
                .HasMaxLength(1);

            this.Property(t => t.DefaultValue)
                .HasMaxLength(100);

            this.Property(t => t.Link_Object)
                .HasMaxLength(100);

            this.Property(t => t.Link_Command)
                .HasMaxLength(100);

            this.Property(t => t.Link_Param1)
                .HasMaxLength(100);

            this.Property(t => t.Link_Param2)
                .HasMaxLength(100);

            this.Property(t => t.Link_Param3)
                .HasMaxLength(100);

            this.Property(t => t.Lookup_Code)
                .HasMaxLength(50);

            this.Property(t => t.Condition_Control)
                .HasMaxLength(100);

            this.Property(t => t.DataField)
                .HasMaxLength(100);

            this.Property(t => t.ArabicName)
                .HasMaxLength(100);

            this.Property(t => t.CaptionVisibility)
                .HasMaxLength(1);

            this.Property(t => t.PrintLayout)
                .HasMaxLength(10);

            // Table & Column Mappings
            this.ToTable("UDF_FieldType");
            this.Property(t => t.id).HasColumnName("id");
            this.Property(t => t.Name).HasColumnName("Name");
            this.Property(t => t.ControlType).HasColumnName("ControlType");
            this.Property(t => t.DataType).HasColumnName("DataType");
            this.Property(t => t.RecordType).HasColumnName("RecordType");
            this.Property(t => t.Category).HasColumnName("Category");
            this.Property(t => t.order).HasColumnName("order");
            this.Property(t => t.Length).HasColumnName("Length");
            this.Property(t => t.ValueList).HasColumnName("ValueList");
            this.Property(t => t.Height).HasColumnName("Height");
            this.Property(t => t.Inactive).HasColumnName("Inactive");
            this.Property(t => t.Page).HasColumnName("Page");
            this.Property(t => t.PrintOntheSameLine).HasColumnName("PrintOntheSameLine");
            this.Property(t => t.NoteSelectionCode).HasColumnName("NoteSelectionCode");
            this.Property(t => t.Caption_Supress).HasColumnName("Caption_Supress");
            this.Property(t => t.Caption_FontSize).HasColumnName("Caption_FontSize");
            this.Property(t => t.Caption_FontColor).HasColumnName("Caption_FontColor");
            this.Property(t => t.Caption_FontBold).HasColumnName("Caption_FontBold");
            this.Property(t => t.Caption_Alignment).HasColumnName("Caption_Alignment");
            this.Property(t => t.FitColumn).HasColumnName("FitColumn");
            this.Property(t => t.Caption_Color).HasColumnName("Caption_Color");
            this.Property(t => t.ShowBullet).HasColumnName("ShowBullet");
            this.Property(t => t.Sep_Show).HasColumnName("Sep_Show");
            this.Property(t => t.Sep_Color).HasColumnName("Sep_Color");
            this.Property(t => t.Sep_Thickness).HasColumnName("Sep_Thickness");
            this.Property(t => t.NoBorder).HasColumnName("NoBorder");
            this.Property(t => t.Message).HasColumnName("Message");
            this.Property(t => t.ReportCode).HasColumnName("ReportCode");
            this.Property(t => t.StatsCode).HasColumnName("StatsCode");
            this.Property(t => t.ImageFile).HasColumnName("ImageFile");
            this.Property(t => t.Transparent).HasColumnName("Transparent");
            this.Property(t => t.Cells).HasColumnName("Cells");
            this.Property(t => t.Name_Arabic).HasColumnName("Name_Arabic");
            this.Property(t => t.Visibility).HasColumnName("Visibility");
            this.Property(t => t.DefaultValue).HasColumnName("DefaultValue");
            this.Property(t => t.SpinnerIncrement).HasColumnName("SpinnerIncrement");
            this.Property(t => t.UID).HasColumnName("UID");
            this.Property(t => t.Private).HasColumnName("Private");
            this.Property(t => t.Link_Enabled).HasColumnName("Link_Enabled");
            this.Property(t => t.Link_Object).HasColumnName("Link_Object");
            this.Property(t => t.Link_Command).HasColumnName("Link_Command");
            this.Property(t => t.Link_Param1).HasColumnName("Link_Param1");
            this.Property(t => t.Link_Param2).HasColumnName("Link_Param2");
            this.Property(t => t.Link_Param3).HasColumnName("Link_Param3");
            this.Property(t => t.Lookup_Code).HasColumnName("Lookup_Code");
            this.Property(t => t.NormalRange_Max).HasColumnName("NormalRange_Max");
            this.Property(t => t.NormalRange_Min).HasColumnName("NormalRange_Min");
            this.Property(t => t.Alert).HasColumnName("Alert");
            this.Property(t => t.TrackHistory).HasColumnName("TrackHistory");
            this.Property(t => t.Condition_Control).HasColumnName("Condition_Control");
            this.Property(t => t.Edit_Alignment).HasColumnName("Edit_Alignment");
            this.Property(t => t.Columns).HasColumnName("Columns");
            this.Property(t => t.GroupCaption_Suppress).HasColumnName("GroupCaption_Suppress");
            this.Property(t => t.DataField).HasColumnName("DataField");
            this.Property(t => t.ArabicName).HasColumnName("ArabicName");
            this.Property(t => t.CaptionVisibility).HasColumnName("CaptionVisibility");
            this.Property(t => t.PrintLayout).HasColumnName("PrintLayout");

            // Relationships
            this.HasOptional(t => t.UDF_Page)
                .WithMany(t => t.UDF_FieldType)
                .HasForeignKey(d => d.Page);

        }
    }
}
